06. Promises with .forEach
Promises with .forEach
Promises with .forEach Quiz
Instructions
First, if you haven't already, read this and follow the instructions on working with the Exoplanet Explorer repo.
- Checkout the
foreach-startbranch and navigate toapp/scripts/app.js. - Refactor
.forEachto create a sequence of Promises that always resolves in the same order it was created.- Fetch each planet's JSON from the array of URLs in the search results.
- Call
createPlanetThumb(data)on each planet's response data to add it to the page.
- Use developer tools to determine if the planets are being fetched in series or in parallel.
There's a typo in the loop that shows up around 1:10! It should look like this:
var x = 0;
for (var i = 0; i < 10; i++) {
x = x + 1;
}
Checkout the foreach-solution branch to see my code!
SOLUTION:
Series2.6 Promises with .forEach Solution